// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   Bird.java

package FlyBird;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JPanel;

public class Bird extends JPanel
{

	BufferedImage images[];
	BufferedImage bird;
	int x;
	int y;
	int width;
	int height;
	int index;
	int key;
	double aphal;
	double v0;
	double v;
	double t;
	double g;
	double s;

	public Bird()
		throws IOException
	{
		images = new BufferedImage[8];
		for (int i = 0; i < 8; i++)
			images[i] = ImageIO.read(getClass().getResource((new StringBuilder("/images/")).append(i).append(".png").toString()));

		key = 0;
		bird = images[0];
		x = 132;
		y = 280;
		index = 0;
		width = bird.getWidth() / 2;
		height = bird.getHeight() / 2;
		v0 = 4D;
		g = 0.5D;
		t = 0.25D;
		s = 0.0D;
		v = v0;
	}

	public void paint(Graphics g)
	{
		super.paint(g);
		Graphics2D g2d = (Graphics2D)g;
		g2d.rotate(aphal, x, y);
		g2d.drawImage(bird, x - width / 2, y - height / 2, width, height, null);
		g2d.rotate(-aphal, x, y);
	}

	public void run()
	{
		index++;
		bird = images[(index / 4) % 8];
		repaint();
	}

	public void initial_v()
	{
		v = v0;
	}

	public void fly()
	{
		s = v * t - (g * t * t) / 2D;
		v -= g * t;
		y = (int)((double)y - s);
		aphal = Math.atan(s / 20D);
	}
}
